export default {
    initData(state, params) {
        state.list.concat(new Array(20).fill(0).map((val, index)=> {
            return {
                id: index,
                name: 'i' + index
            }
        }));
        return {
            ...state
        }
    },

    addItem(state, item) {
        state.list.push(item);
        return {
            ...state
        }
    },

    updateItem(state, id, item) {
        let idx = this.list.indexOf(val=> val.id=== id);
        state.list[idx] = item;
        return {
            ...state
        }
    },

    deleteItem(state, id) {
        let idx = this.list.indexOf(val=> val.id=== id);
        state.list.splice(idx, 1);
        return {
            ...state
        }
    }
}